using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using System.Windows.Forms;
using System.Reflection;
using System.Threading;
using DevExpress.Persistent.BaseImpl;
using System.Collections;
using System.IO;
using RemoteDll;

namespace AppSolution.Module
{
    public class StaticAppDomain
    {
        public static Loader loader;
    }
    public partial class ButtonController : ViewController
    {
        public ButtonController()
        {
            InitializeComponent();
            RegisterActions(components);
        }

        private void GetFilePath_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            //var list = XafTypesInfo.XpoTypeInfoSource.RegisteredEntities;
            InterFaceData s = ObjectSpace.CreateObject<InterFaceData>();
            MessageBox.Show(s.SumMethod(1, 3));
            //foreach (var item in list)
            //{
            //    MessageBox.Show(item.FullName);                
            //}
        }

        private void LoadDll_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            StaticAppDomain.loader = new Loader();
            //StaticAppDomain.loader.LoadAssembly(@"C:\Users\jiangxf\Desktop\AppSolution\DllModule\bin\Debug\DllModule.dll");
            StaticAppDomain.loader.LoadAssembly(@"C:\Users\jiangxf\Desktop\AppSolution\AppSolution.Win\bin\Debug\DllModule.dll");
        }

        private void ReadDll_Execute(object sender, SimpleActionExecuteEventArgs e)
        {            
            var s = StaticAppDomain.loader.rl.Invoke("DllModule.DomainObject.Oper", "CreateObject", ObjectSpace);
            //StaticAppDomain.loader.rl.assembly;
            //var s = ObjectSpace.CreateObject(Type.GetType("DllModule.DomainObject"));
            BaseObject bo = s as BaseObject;
            bo.SetMemberValue("A", "aaa");
            bo.Save();
        }

        private void UnloadDll_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            StaticAppDomain.loader.Unload();
        }
    }
}

